<!DOCTYPE html>

<html>
  <head>
    <title>Portal de Compras</title>
    <%= stylesheet_link_tag    "application", :media => "all" %>
    <%= javascript_include_tag "application" %>
    <%= csrf_meta_tags %>
  </head>
  <body>
  
    <div id="wrapper">
      <header id="header">
        <div id="login">
          <% if session['user'] %>
            <p align='right'>
			  <% if session['cliente'] && session['cliente'].length == 3 && session['cliente'][2].length > 0 %>
				Seja bem vindo <%= session['cliente'][2][0][1] %>.
			  <% else %>
				Seja bem vindo <%= session['user'] %>.
			  <% end %>
              <a href="/logout">Logout</a>
            </p>
          <% else %>
           <a href="/login">Login</a>
            <a href="/login/newuser"></a>
          <% end %>
        </div>
        
        <div id="logo">
          <h1><%= link_to "Portal de Compras - G12", {:controller => 'home', :action => 'index'} %></h1>
          <p><em> MC747 - Projeto de Engenharia de Software</em></p>
	</div>
		
        <hr />
        <!-- end #logo -->

        <div id="menu">
          <ul>
            <li><%= link_to "Home", "/" %></li>
			<% if session['user'] %>
				<li class="current_page_item"><%= link_to "Meus Dados", "/customers/#{session['user']}" %></li>
				<li><%= link_to "Meus Pedidos", purchases_path %></li>
				<li><a href="/tickets">Atendimento</a></li>
			<% end %>
          </ul>
        </div>
        <!-- end #menu -->
        <div id="search">
          <%= form_tag("/products/search", :method => "get") do %>
            <%= text_field_tag(:for_word) %>
            <%= submit_tag("Buscar") %>
          <% end %>
          
        </div>
        <!-- end #search -->
      </header>
      
      <!-- end #header-wrapper -->
      <div id="page">
        <div id="page-bgtop">
          <div id="content">
            
            <%= yield %>
            
          </div>
          <!-- end #content -->
          <div id="sidebar">
            <ul>
              <li>
                <h2>Categorias</h2>
              
                <%= render "home/categories" %>
                
              </li>
              
			  <% if session['user'] %>
				  <li>
					<h2>Carrinho</h2>
					<div id="cart">
					  <%= render "home/cart" %>
					</div>
				  </li>
			  <% end %>
              
            </ul>
          </div>
          <!-- end #sidebar -->
          <div style="clear: both;">&nbsp;</div>
        </div>
      </div>
      <!-- end #page -->
      
      <footer id="footer-bgcontent">
        <div id="footer">
          <p>Copyright (c) 2012. All rights reserved.</p>
        </div>
      </footer>
      
    </div>
  </body>
</html>
